package cn.hxz.mapper;

import cn.hxz.pojo.Teacher;
import org.apache.ibatis.annotations.*;

import java.util.List;

//使用注解方式处理
public interface TeacherOtherMapper {

    //查询所有
    @Select("select * from teacher  limit ${(pageIndex-1)*pageSize}, ${pageSize} ")
    public List<Teacher> selectAll(@Param("name") String name,
                                   @Param("pageIndex") int pageIndex, @Param("pageSize") int pageSize);

    //新增
    @Insert("insert teacher(name, sex, phone, age) values (#{name}, #{sex}, #{phone}, #{age})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    public void insert(Teacher teacher);

    //编辑
    @Update("update teacher set name=#{name},sex=#{sex},phone=#{phone},age=#{age}")
    public void update(Teacher teacher);

    //删除
    @Delete("delete from teacher where id =#{id}")
    public void delete(int id);

    //单条查询
    @Select("select from teacher where id = #{id} ")
    public Teacher selectOne(int id);
}
